﻿using System;
using System.Collections.Generic;
using System.Text;
using SQLite;

namespace DailyDiet.Models
{
    [Serializable]
    [SQLite.Table("diet")]
    public class Diet {
        /*蛋白质	  脂肪	  糖类	       纤维素	维生素	碳水化合物
         Protein, fat, sugars, cellulose, vitamin, carbohydrate*/
        /// <summary>
        /// id
        /// </summary>
        [PrimaryKey,SQLite.Column("Id")]
        public int Id { set; get; }

        [SQLite.Column("name")]
        public string Name { set; get; }

        [SQLite.Column("picture")]
        public string PictureURL { set; get; }

        [SQLite.Column("describe")]
        public string Describe { set; get; }

        //营养物质
        /// <summary>
        /// 蛋白质
        /// </summary>
        [SQLite.Column("protein")]
        public double Protein { set; get; }

        [SQLite.Column("fat")]
        public double Fat { set; get; }

        [SQLite.Column("sugars")]
        public double Sugars { set; get; }

        [SQLite.Column("cellulose")]
        public double Cellulose { set; get; }

        [SQLite.Column("vitamin")]
        public double Vitamin { set; get; }

        [SQLite.Column("carbohydrate")]
        public double Carbohydrate { set; get; }

        //口味偏好
        [SQLite.Column("spicy")]
        public double SpicyIndex { set; get; }

        [SQLite.Column("sweetness")]
        public double SweetIndex { set; get; }

        [SQLite.Column("tag")]
        public int Tag { get; set; }

        [SQLite.Column("kind")]
        public string Kind { set; get; }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(obj, null)) return false;
            if (ReferenceEquals(this, obj)) return true;
            var o = obj as Diet;
            if (o.Id == null && obj == null) {
                return false;
            }
            return o.Id == this.Id;
        }

        public override int GetHashCode() {
            return base.GetHashCode();
        }

        public override string ToString() {
            return base.ToString();
        }
    }

    public static class PropertyConstant
    {
        public const string Protein = "Protein";
        public const string Fat = "Fat";
        public const string Sugars = "Sugars";
        public const string Cellulose = "Cellulose";
        public const string Carbohydrate = "Carbohydrate";
        public static readonly string[]
            Properties = new[] { "Protein", "Fat", "Sugars", "Cellulose", "Vitamin",
                "Carbohydrate" };
    }

    public static class DietConstant {
        public const int BreakfastTag = 1;
        public const int NotBreakfastTag = 0;

        public const string BreakfastKind1 = "b-1";
        public const string BreakfastKind2 = "b-2";

        /// <summary>
        /// 面食类
        /// </summary>
        public const string Noodle = "a-1";

        /// <summary>
        /// 荤菜类
        /// </summary>
        public const string Meat = "a-2";

        /// <summary>
        /// 蔬菜类
        /// </summary>
        public const string Vegetable = "a-3";

        /// <summary>
        /// 米饭类
        /// </summary>
        public const string Rice = "a-4";

        public static readonly string[] Properties = new string[] {
            "Protein", "Fat", "Sugars", "Cellulose", "Vitamin",
            "Carbohydrate"
        };

        public static Dictionary<string, string> PropertiesToColorsDict = new Dictionary<string, string>() {
            {"Protein", "#FF3366"},
            {"Fat", "#FF6600"},
            {"Sugars", "#FFFFCC"},
            {"Cellulose", "#33FF00"},
            {"Vitamin", "#0000FF"},
            {"Carbohydrate", "#990099"}
        };
    }
}
